package com.example.introductiontoprogramming;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Programming7 extends AppCompatActivity {

    private EditText edtTxtMaina;
    private Button btnMainJisuan;
    private TextView tvMainResult, tvMainResult2, tvMainResult3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.programming_main7);

        initView();

    }

    private void initView() {
        edtTxtMaina = (EditText) findViewById(R.id.edtTxtMaina);
        btnMainJisuan = (Button) findViewById(R.id.btnMainJisuan);
        tvMainResult = (TextView) findViewById(R.id.tvMainResult);
        tvMainResult2 = (TextView) findViewById(R.id.tvMainResult2);
        tvMainResult3 = (TextView) findViewById(R.id.tvMainResult3);

    }

    public void dealonClick(View view) {

        String a = edtTxtMaina.getText().toString();
        if (a.length() == 0) {
            Toast.makeText(Programming7.this, "请输入数字", Toast.LENGTH_SHORT).show();
        } else {
            //长度
            tvMainResult.setText(String.valueOf(a.length()));

            //分别输出
            int b = Integer.parseInt(a);
            tvMainResult2.setText(String.valueOf(b)+" ");

            //逆序
            StringBuffer num = new StringBuffer(String.valueOf(b));
            tvMainResult3.setText(num.reverse());

        }
    }
}